package Empleado.Controller;

import java.util.Calendar;
import java.util.GregorianCalendar;



import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.proyecto.exception.DAOExcepcion;

import Empleado.Service.EmpleadoService;
import SanIsidro.modelo.Empleado;

@Controller
public class EmpleadoController {
@Autowired
	private EmpleadoService empleadoService;

@RequestMapping(value = "/empleado_grabar" )	
protected ModelAndView insertarEmpleado(HttpServletRequest request,
		HttpServletResponse response) throws Exception {
	
	Calendar c2 = new GregorianCalendar();
	Empleado emp=new Empleado();
	avi.setIdOfertante(1);
	avi.setId_area(1);
	avi.setTitulo(request.getParameter("titulo"));
	avi.setFec_publicacion(c2.getTime());
	avi.setFec_caduc(c2.getTime());
	avi.setDescripcion(request.getParameter("descripcion"));
	
	try {
		avisoService.insertar(avi);
	} catch (DAOExcepcion e) {
		return new ModelAndView("/avisos_ofertante", "mensaje", e.getMessage());
	}
	
	return new ModelAndView("/avisos_ofertante","mensaje","El aviso se grabo correctamente");
}
}
